<?php
/**
 * Created by PhpStorm.
 * User: mac
 * Date: 2018/6/23
 * Time: 10:17
 */

namespace app\common\model;


use think\Model;

class Audios extends Model
{
    public function getAudiosById($id){
        if(!$id && !is_numeric($id)){
            exception("传递的ID不合法");
        }

        $where = array(
            'status'=>1,
            'course_id'=> $id,
        );
        return $this->where($where)->field("id,is_audition,timelong,tag,title,content")->select();
    }

    public function getCourseAudioById($id){
        if(!$id && !is_numeric($id)){
            exception("传递的ID不合法");
        }

        $where = array(
            'a.id' => $id
        );
        return $this->alias("a")->join("xm_courses c","a.course_id=c.id")->where($where)->field("c.id as CourseId,c.title as CourseTitle,a.content,c.img_url,a.url as Path,a.sort,a.title")->find();
    }
}